//
//  MCNoVideoTrainTableCell.swift
//  MCBodyBuildingPro
//
//  Created by Renlvshijie on 2023/6/18.
//

import UIKit
import MBCircularProgressBar
 

typealias noVideoTrainBlock = (_ indexNextPath:IndexPath) -> Void

class MCNoVideoTrainTableCell: UITableViewCell {
    
    
    public var indexPath:IndexPath!
    
    @IBOutlet weak var currentActionLabel: UILabel!
    
    @IBOutlet weak var currentHeaderZuActionLabel: UILabel!
    
    @IBOutlet weak var timeAndProgressLabel: UILabel!
    
    @IBOutlet weak var circularProgressBar: MBCircularProgressBarView!
    
    @IBOutlet weak var playVideoTrainView: UIImageView!
    
    var nextPath:noVideoTrainBlock?
    
    
    public var timeBreakTime:Int = 0 {
        didSet {
            if timeBreakTime == 0 {
                
            }else{
               
                self.circularProgressBar.maxValue = CGFloat(timeBreakTime)
                
                WLButtonCountdownManager.default().scheduledCountDown(withKey: "\(self.indexPath.row)", timeInterval:TimeInterval(timeBreakTime)) { breakTimeInteral in
                    
                    print(breakTimeInteral)
                    
                    UIView.animate(withDuration: 1.0) {
                        DispatchQueue.main.async {
                            self.circularProgressBar.value = breakTimeInteral
                        }
                    }
                    
                    if breakTimeInteral == 1.0 {
                        
                        self.nextPath?(IndexPath.SubSequence(row: self.indexPath.row + 1, section: self.indexPath.section))
                    }
                    
                }
            }
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.circularProgressBar.countdown = false
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

       
    }
    
}
